#include <limits.h>
#include <math.h>
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>

int* partitionLabels(char* s, int* returnSize);

int main()
{
	return 0;
}

inline int max(int x, short y);
int max(int x, short y)
{
	return x > y ? x : y;
}
/**
 * Note: The returned array must be malloced, assume caller calls free().
 */
int* partitionLabels(char* s, int* returnSize)
{
	short aux[26] = { 0 };
	int len = 0;
	for (; s[len]; len++)
		aux[s[len] - 'a'] = len;

	int* res = calloc(len, sizeof(int));
	int end = 0, start = 0, size = 0;
	for (int i = 0; i < len; i++) {
		end = max(end, aux[s[i] - 'a']);
		if (i == end) {
			res[size++] = end - start + 1;
			start = end + 1;
		}
	}

	*returnSize = size;
	return res;
}
